/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.una.pol.ii.is2.domain.flota;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author markos
 */
@Entity
@Table(name = "marca_modelo")
@NamedQueries({@NamedQuery(name = "MarcaModelo.findAll", query = "SELECT m FROM MarcaModelo m"), @NamedQuery(name = "MarcaModelo.findByMamoCodMarca", query = "SELECT m FROM MarcaModelo m WHERE m.marcaModeloPK.mamoCodMarca = :mamoCodMarca"), @NamedQuery(name = "MarcaModelo.findByMamoCodModelo", query = "SELECT m FROM MarcaModelo m WHERE m.marcaModeloPK.mamoCodModelo = :mamoCodModelo")})
public class MarcaModelo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected MarcaModeloPK marcaModeloPK;
    @OneToMany(cascade = CascadeType.MERGE, mappedBy = "marcaModelo")
    private Collection<Vehiculo> vehiculoCollection;
    @JoinColumn(name = "mamo_cod_marca", referencedColumnName = "marc_cod", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Marca marca;
    @JoinColumn(name = "mamo_cod_modelo", referencedColumnName = "mode_cod", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Modelo modelo;

    public MarcaModelo() {
    }

    public MarcaModelo(MarcaModeloPK marcaModeloPK) {
        this.marcaModeloPK = marcaModeloPK;
    }

    public MarcaModelo(int mamoCodMarca, int mamoCodModelo) {
        this.marcaModeloPK = new MarcaModeloPK(mamoCodMarca, mamoCodModelo);
    }

    public MarcaModeloPK getMarcaModeloPK() {
        return marcaModeloPK;
    }

    public void setMarcaModeloPK(MarcaModeloPK marcaModeloPK) {
        this.marcaModeloPK = marcaModeloPK;
    }

    public Collection<Vehiculo> getVehiculoCollection() {
        return vehiculoCollection;
    }

    public void setVehiculoCollection(Collection<Vehiculo> vehiculoCollection) {
        this.vehiculoCollection = vehiculoCollection;
    }

    public Marca getMarca() {
        return marca;
    }

    public void setMarca(Marca marca) {
        this.marca = marca;
    }

    public Modelo getModelo() {
        return modelo;
    }

    public void setModelo(Modelo modelo) {
        this.modelo = modelo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (marcaModeloPK != null ? marcaModeloPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MarcaModelo)) {
            return false;
        }
        MarcaModelo other = (MarcaModelo) object;
        if ((this.marcaModeloPK == null && other.marcaModeloPK != null) || (this.marcaModeloPK != null && !this.marcaModeloPK.equals(other.marcaModeloPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.ii.is2.dao.flota.MarcaModelo[marcaModeloPK=" + marcaModeloPK + "]";
    }

}
